<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8"/>
	<title>汽车保养与维修系统</title>
	<link href="<?php echo base_url('web');?>/css/bootstrap.min.css" rel="stylesheet" />
	<script src="<?php echo base_url('web')?>/js/jquery-3.2.0.min.js" ></script>
	<script src="<?php echo base_url('web')?>/js/bootstrap.min.js" ></script>
</head>
<body style="padding:100px;">
	<div class="panel panel-default">
		<!-- Default panel contents -->
		<div class="panel-heading"><h1><?php echo $title;?></h1></div>
		<div class="panel-body">
		    <?php echo $content;?>
		</div>
		<div class="panel-body">
			<select id="type" name="type">
				<option value="0">请选择车型</option>
				<?php 
					$str ='';
					foreach($type as $v){
						$str .= '<option value="'.$v["classid"].'">'.$v["name"].'</option>';
					}
					echo $str;
				?>
			</select>
		</div>
		<div class="button-group" role="group" style="width:100%;">
			<button id="reserve" type="button" style="width:100%;" class="btn btn-default wq-btn">预约</button>
		</div>
	</div>
	<script>
		var discounts = {
			<?php
				$str = '';
				foreach($type as $v){
					$str .= $v['classid'].':'.$v['weight'].',';
				}
				echo $str;
			?>
		};
		var price = <?php echo $price;?>;
		var discount = <?php echo $discount;?>;
		$('#reserve').on('click',function(){
			var typeClass = $('#type').val();
			if(typeClass==0){
				alert('请选择车型');
				return;
			}
			if(confirm('共计价格'+(price*discounts[typeClass]*discount*0.1)+',是否预约？')){
				$.get('<?php echo base_url('index.php/reservation/reserve/'.$id);?>' + '/' + typeClass,{},function(res){
					if(res.code == 200){
						alert(res.data.msg);
						console.log(window.parent);
						window.parent.$lis.removeClass('active');
						window.parent.$myReservation.addClass('active');
						window.location.href = window.parent.RESERVATION_URL;
					}else{
						alert(res.msg);
						if(res.code == 401){
							window.parent.login();
						}
					}
				},'json');
			}
		});
	</script>
</body>
</html>